/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-13 15:52:29
 * @LastEditTime: 2019-12-17 00:31:42
 * @LastEditors: YJP
 */
import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

const routes = [
  {
    path:"/",
    component:()=>import('./view/index/Login.vue'),
  },
  {
    path:"/active",
    name:'Active',
    component:()=>import('./view/index/Active.vue'),
  },
  {
    path:"/add",
    name:"Add",
    component:()=>import('./view/index/Add.vue'),
  },
  {
    path:"/chat",
    name:'Chat',
    component:()=>import('./view/index/Chat.vue'),
  },
  {
    path:"/map",
    name:'Map',
    component:()=>import('./view/index/Map.vue'),
  },
  {
    path:"/music",
    name:'Music',
    component:()=>import('./view/index/Music.vue'),
  },
  {
    path:"/>_<",
    name:'>_<',
    component:()=>import('./view/index/small.vue'),
  },
  {
    path: '*',
    redirect: '/404'
  },
  {
    path: '/404',
    component: () => import('./view/404'),
    meta: {
      title: '404'
    }
  },
];

// add route path
routes.forEach(route => {
  route.path = route.path || '/' + (route.name || '');
});

const router = new Router({ routes });

router.beforeEach((to, from, next) => {
  const title = to.meta && to.meta.title;
  if (title) {
    document.title = title;
  }
  next();
});

export {
  router
};
